import authapi from './authapi'

/* eslint-disable */
export const GetPermissionList = () => {
  let api = new authapi('getPermission')

  return api.Send({}, {})
}

export const GetPermissionById = (id) => {
  let api = new authapi('getPermission')

  let paramList = [id]

  return api.Send({}, {}, paramList)
}

export const AddPermission = (path, description) => {
  let api = new authapi('addPermission')

  let data = {
    'permission_code': path,
    'description': description,
    // 'status': 1,
    // 'ext_infos': {}
  }

  return api.Send({}, data)
}

export const UpdatePermission = (id, path, description) => {
  let api = new authapi('putPermission')

  let paramList = [id]

  let data = {
    'permission_code': path,
    'description': description,
    'id': id,
    // 'ext_infos': {}
  }

  return api.Send({}, data, paramList)
}

export const DeletePermission = id => {
  let api = new authapi('delPermission')

  let paramList = [id]

  return api.Send({}, {}, paramList)
}

export const GetUserByPermission = id => {
  let api = new authapi('getUserByPermission')

  let paramList = [id, 'users']

  return api.Send({}, {}, paramList)
}

export const GetRoleByPermission = id => {
  let api = new authapi('getRoleByPermission')

  let paramList = [id, 'roles']

  return api.Send({}, {}, paramList)
}

export default {
  GetPermissionList,
  GetPermissionById,
  AddPermission,
  UpdatePermission,
  DeletePermission,
  GetUserByPermission,
  GetRoleByPermission
}
